package com.ldw.algorithm;

public class MaxDifferenceElement {

    public static int maxdiff(int a[]) {
        int maxDiff = 0;
        if (a.length < 2) {
            return maxDiff;
        }

        for (int i = 0; i < a.length - 1; i++) {
            if (Math.abs(a[i + 1] - a[i]) > maxDiff) {
                maxDiff = Math.abs(a[i + 1] - a[i]);
            }
            a[i] = a[i + 1];
        }
        return maxDiff;
    }

    public static void main(String[] args) {
        int a[] = {19, 1, 2, 33, 4};
        System.out.println(maxdiff(a));
    }
}
